<?php
// No directAcces
defined('_AppBackMiage') or die('Restricted access');
if(isAdministrateur ()){
    include_once (DS . "backoffice/include/header.php");
    include_once( DS . "backoffice/include/toppanel_portail.php");
    ?>
    <div id="wrapper">
        <div id="content">
            <div id="rightnow">
                <?php
                $title = "Technologies";
                $add = '<a href="' . URL . 'index.php?m=admin_portailtechnologie_add" class="add">Ajouter une Technologie</a>';
                ?>

                <h3 class="reallynow">
                    <span>Liste des <?php echo $title; ?></span>
                    <?php echo $add;
                    echo $csv; ?>
                    <br />
                </h3>
                </p>
                <p class="youhave">
                    <?php
                        $nbrResultPerPage = 10;

                        if (isset($_GET['page']) && !empty($_GET['page'])){
                            $page = $_GET['page'];
                            $nbr = (((int) $_GET['page'] - 1) * $nbrResultPerPage);
                            $listeTechnologie = Technologie::getList($nbrResultPerPage, $nbr);
                        }
                                            else {
                            $page = 1;
                            $listeTechnologie = Technologie::getList($nbrResultPerPage, 0);
                        }

                        $count = Technologie::globalCount();
                        $pages = ceil($count / $nbrResultPerPage);
                        $pageSuivante = $page + 1;
                        $pagePrecendente = $page - 1;
                        if (!empty($listeTechnologie)){
                                                    ?>
                                                    <table width="100%">
                                                            <thead>
                                                                    <tr>
                                                                            <th>Technologie</th>
                                                                            <th>Action</th>
                                                                    </tr>
                                                            </thead>
                                                            <tbody>
                                                    <?php

                                                    foreach ($listeTechnologie as $technologie){
                                                            $editURL = URL . "/index.php?m=admin_portailtechnologie_edit&uid=".$technologie->idTechnologie;
                                                    ?>
                                                                    <tr>
                                                                            <td><?php echo $technologie->NomTechnologie; ?></td>
                                                                            <td class="a-center">
                                                                                    <a href="<?php echo $editURL; ?>">
                                                                                            <img src="<?php echo STYLEBK; ?>img/icons/user_edit.png" title="Edit techno" width="16" height="16" />
                                                                                    </a>
                                                                            </td>
                                                                    </tr>
                                            <?php
                                            }
                                            ?>
                                </tbody>
                         </table>

                             <div id="pager">
                            Page
                    <?php if ($pagePrecendente > 0): ?>
                                <a href="<?php echo URL . "/index.php?m=admin_portailtechnologie_list&page=" . $pagePrecendente; ?>&tid=0&name=<?php echo $_GET['name']; ?>&promo=<?php echo $_GET['promo']; ?>"><img src="<?php echo STYLEBK; ?>img/icons/arrow_left.gif" width="16" height="16" /></a>
                    <?php endif; ?>
    <?php echo $page; ?>
                    <?php if ($pageSuivante <= $pages): ?>
                                    <a href="<?php echo URL . "/index.php?m=admin_portailtechnologie_list&page=" . $pageSuivante; ?>&tid=0&name=<?php echo $_GET['name']; ?>&promo=<?php echo $_GET['promo']; ?>"><img src="<?php echo STYLEBK; ?>img/icons/arrow_right.gif" width="16" height="16" /></a>
    <?php endif; ?>
                            sur <?php echo $pages; ?> | Total <strong><?php echo $count; ?> </strong> technologies trouv&eacute;es.
                        </div>
                        <?php
                                            }
                                            else{
                                                    echo 'rien';
                                            }
                                    ?>
                    </p>
                </div>
            </div>
        <?php
            include_once (DS . "backoffice/include/sidebar.php");
            include_once (DS . "backoffice/include/footer.php");
}
else
{
    redirectTo(URLBACK);
}
?>